{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Monthly test results for 2018"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Imports libraries.\n",
    "%matplotlib inline\n",
    "import matplotlib as mpl\n",
    "import matplotlib.pyplot as plt\n",
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Read input files.\n",
    "data = {'Lite': [], 'Advanced': [], 'Rider': []}\n",
    "for v in data.keys():\n",
    "    for m in range(1, 13):\n",
    "        data[v].append(pd.read_json('%s/_results/EA31337_%s_2018%02d.json' % (v.lower(), v, m), typ='series'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "for field in ['Profit factor', 'Expected payoff', 'Total net profit', 'Gross profit', 'Gross loss', 'Absolute drawdown', 'Total trades', 'Bars in test', 'Ticks modelled']:\n",
    "    fig = plt.figure(figsize=(20, 5))\n",
    "    ax = fig.add_subplot(111)\n",
    "    ind = np.arange(1, 13)\n",
    "    width = 0.27\n",
    "    bar1 = ax.bar(ind-width, [float(v[field]) for v in data['Lite']], width, color='greenyellow')\n",
    "    bar2 = ax.bar(ind, [float(v[field]) for v in data['Advanced']], width, color='lime')\n",
    "    bar3 = ax.bar(ind+width, [float(v[field]) for v in data['Rider']], width, color='orchid')\n",
    "    ax.legend( (bar1[0], bar2[0], bar3[0]), ('Lite', 'Advanced', 'Rider') )\n",
    "    plt.xticks(np.arange(min(ind), max(ind)+1, 1))\n",
    "    plt.title(field);\n",
    "    plt.xlabel('Month', labelpad=1)\n",
    "    plt.ylabel(field)\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
